<?php
use services\models\OrderInfoDetail;
?>

<?php $this->beginBlock('css');?>
<link rel="stylesheet" type="text/css" href="<?= Yii::getAlias('@static')?>/pc/liketry/css/user.css">
<?php $this->endBlock();?>
<!--表头-->
<?= $this->render('@liketry/views/layouts/header_goods.php',['top_ad_show'=>false])?>
<!-- 顶部拉幕广告&&搜索框 Start -->
<div class="header"></div>
<!-- 顶部拉幕广告&&搜索框 End -->

<!-- 主体内容 Start -->
<div class="usermain">
    <?= $this->render('@liketry/views/left/left.php') ; ?>
    <?php if($orderInfo) :?>
	<div class="main-right order-detail">
		<h1>订单详情</h1>
		<h2>订单号：<span class="order-id"><?=$orderInfo->order_sn?></span>       订单状态：

            <?php if ($orderInfo->status == OrderInfoDetail::$STATUS_ORDER_CREATED): ?>
            	<?php if(strtotime($orderInfo->create_time)- strtotime("-12 hours")>0) :?>
                    <?php if($orderInfo->pay_status ==OrderInfoDetail::$PAY_STATUS_FAIL || $orderInfo->pay_status==OrderInfoDetail::$PAY_STATUS_WAIT) :?>
                     <span class="order-state">待付款</span>
                    <?php elseif ($orderInfo->pay_status ==OrderInfoDetail::$PAY_STATUS_CANCEL): ?>
                      <span class="order-state">已取消</span>
                    <?php endif;?>
                <?php else :?>
                    <span class="order-state">已取消</span>
                <?php endif;?>
            <?php elseif ($orderInfo->status == OrderInfoDetail::$STATUS_PAYED): ?>
                <span class="order-state">待发货</span>
            <?php elseif (in_array($orderInfo->status, OrderInfoDetail::$STATUS_IN_KEY)): ?>
                <span class="order-state">待收货</span>
            <?php elseif ($orderInfo->status == OrderInfoDetail::$STATUS_ORDER_OK): ?>
	             <?php if ($orderGoods['flg'] == 0): ?>
	             <span class="order-state">待评价</span>
	            <?php else:?>
	                <span class="order-state">已完成</span>
	             <?php endif; ?>
            <?php elseif ($orderInfo->status == OrderInfoDetail::$STATUS_ORDER_CANCEL): ?>
                <span class="order-state">已取消</span>
            <?php endif; ?>
        </h2>
	
		
		<div class="wuliu">
            <?php if(isset($orderInfo->lgistics->delivery_id) && array_key_exists($orderInfo->lgistics->delivery_id,OrderInfoDetail::$EXPRESS_INFO)):?>
			<p class="wuliu-company">发货方式：快递<br>
                物流公司：<?=OrderInfoDetail::$EXPRESS_INFO[$orderInfo->lgistics->delivery_id] ?>

                </p>
                <br>
                物流单号：<?php if(isset($orderInfo->lgistics->delivery_code)):?><?=$orderInfo->lgistics->delivery_code?><?php endif;?></p>
            <?php endif;?>
            <?php if($logic) :?>
            <dl class="<?php if (count($logic)>3):?>open<?php endif ;?>" >
                <dt>
					<div class="time">操作时间</div>
					<div class="log">包裹日志</div>
					<div class="mes">备注信息</div>
				</dt>

                <?php foreach($logic as $val) :?>
                <dd>
					<div class="time"><?php echo $val['exec_time'];?></div>
					<div class="log"><?=$val['exec_address'] ?><i class="icon icon-wuliu"></i></div>
					<div class="mes"><?=$val['exec_remark'] ?></div>
				</dd>
                <?php endforeach ;?>
			</dl>
			<?php if (count($logic)>3):?><a class="more">查看全部</a><?php endif ;?>
			<?php endif ;?>
		</div>
		
		<div class="receive-goods">
			<ul>
            <?php if($orderInfo->lgistics) :?>
			<li class="column">
				<div class="title">收货人信息</div>
				<p><span class="key">收货人：</span><span><?=$orderInfo->lgistics->consignee ;?></span></p>
				<p><span class="key">地&nbsp;&nbsp;&nbsp;址：</span><span><?=$orderInfo->lgistics->province ;?> <?=$orderInfo->lgistics->city ;?> <?=$orderInfo->lgistics->county ;?></span></p>
           		<p class="ellipsis"><?=$orderInfo->lgistics->address ;?></p>
				<p><span class="key">电&nbsp;&nbsp;&nbsp;话：</span><span><?=$orderInfo->lgistics->mobile_phone ;?></span></p>
			</li>
            <?php endif;?>
			<li class="column">
				<div class="title">邮费信息</div>
				<p>您的邮费为
                    <?php if($orderInfo->ship_amount  !=0):?>
                    <?=Yii::$app->formatter->asDecimal($orderInfo->ship_amount,2)?>元<br>
                    <?php else :?>
                        ¥0.00
                    <?php endif;?>
                <?php if($orderInfo->ship_amount_try_coin  !=0):?>    （已用<?=$orderInfo->ship_amount_try_coin ;?>试豆抵扣）<?php endif;?>
                </p>
			</li>
			<li class="column">
				<div class="title">支付信息</div>
				<p>支付状态：<?php echo OrderInfoDetail::$PAY_STATUS[$orderInfo->pay_status]?><br>
                    <?php if(!empty($orderInfo->pay_name)):?>支付方式：<?=$orderInfo->pay_name ;?><?php endif;?></p>
			</li>
			<li class="column">
				<div class="title">试豆信息</div>
				<p>可获得试豆：0</p>
				<div class="btn">
					<a href="<?php echo Yii::$app->params['domains']['liketry_url'].'info/intro.php?id=10004';?>"  target="_blank">试豆使用规则</a>
					<a href="<?php echo Yii::$app->params['domains']['liketry_url'].'member/user_xiyuan.php';?>" target="_blank">查看我的试豆</a>
				</div>
			</li>
			</ul>
			<div class="clear"></div>
		</div>
		<?php if (count($orderGoods) > 0) :?>
        <div class="goods-list">
			<div class="title">商品清单</div>
			<table>
				<thead>
					<tr>
						<th class="name" width=330>商品名称</th>
						<th class="price" width=128>商品价格</th>
						<th class="num" width=98>商品数量</th>
						<th class="total" width=128>金额小计</th>
						<th class="action">状态</th>
					</tr>
				</thead>
				
				<?php foreach($orderGoods['data'] as $vals ) :?>

                <tr>
					<td class="name"><?=$vals['goodPic']['goods_name']?></td>
					<td class="price">
                        <?php if($vals['buy_price'] > 0) :?><p>￥<?=Yii::$app->formatter->asDecimal($vals['buy_price'],2)?></p><?php endif;?>
                        <?php if($vals['try_coin'] > 0) :?><p><?=$vals['try_coin'] ?>试豆</p><?php endif;?>
                        <?php if($vals['try_coin'] == 0 && $vals['buy_price'] ==0) :?>
                            ￥0.00
                        <?php endif;?>
                    </td>
					<td class="num"><?=$vals['buy_number'] ?></td>
					<td class="total">
                        <?php if($vals['buy_price'] != 0) :?><p>￥<?=Yii::$app->formatter->asDecimal($vals['buy_number'] * $vals['buy_price'],2)?></p><?php endif;?>
                        <?php if($vals['try_coin'] != 0) :?><p> <?=$vals['buy_number'] * $vals['try_coin'] ?>试豆</p><?php endif;?>
                        <?php if($vals['try_coin'] == 0 && $vals['buy_price'] ==0) :?>
                            ￥0.00
                        <?php endif;?>
                    </td>
					<td class="action">
						<?php if ($orderInfo->status == OrderInfoDetail::$STATUS_ORDER_CREATED): ?>
			            	<?php if(strtotime($orderInfo->create_time)- strtotime("-12 hours")>0) :?>
			                    <?php if($orderInfo->pay_status ==OrderInfoDetail::$PAY_STATUS_FAIL || $orderInfo->pay_status==OrderInfoDetail::$PAY_STATUS_WAIT) :?>
			                      待付款
			                    <?php elseif ($orderInfo->pay_status == OrderInfoDetail::$PAY_STATUS_CANCEL): ?>
			                      已取消
			                    <?php endif;?>
			                <?php else :?>
			                    <span class="order-state">已取消</span>
			                <?php endif;?>
			            <?php elseif ($orderInfo->status == OrderInfoDetail::$STATUS_PAYED): ?>
			                待发货
			            <?php elseif (in_array($orderInfo->status, OrderInfoDetail::$STATUS_IN_KEY)): ?>
			                待收货
			            <?php elseif ($orderInfo->status == OrderInfoDetail::$STATUS_ORDER_OK): ?>
				             <?php if ($orderGoods['flg'] == OrderInfoDetail::$STATUS_COMMENT_NO && $vals['commented']==OrderInfoDetail::$STATUS_COMMENT_NO ): ?>
				             <a href="<?=Yii::$app->urlManager->createUrl(["comments/index",'order_info_id'=>$orderInfo->order_info_id,'goods_id'=>$vals['goods_id']]);?>" target="_blank">评论获试豆</a>
				            <?php else:?>
				                已评价
				             <?php endif; ?>
			            <?php elseif ($orderInfo->status == OrderInfoDetail::$STATUS_ORDER_CANCEL): ?>
			                已取消
			            <?php endif; ?>
					</td>
					
				</tr>
                <?php endforeach ; ?>
			</table>

            <p class="goods-total">商品总额：
                <?php if($orderInfo->goods_amount != 0) :?> ¥<?=Yii::$app->formatter->asDecimal($orderInfo->goods_amount,2)?><?php endif;?>
                <?php if($orderInfo->goods_amount != 0 && $orderInfo->try_coin != 0) :?>+<?php endif;?>
                <?php if($orderInfo->try_coin != 0) :?><?=$orderInfo->try_coin?>试豆<?php endif;?>
            </p>

            <?php if($orderInfo->reduce_amount != 0 || $orderInfo->coupon_amount != 0 ) :?>
                <p class="goods-total">
                优惠金额：-¥<?=Yii::$app->formatter->asDecimal($orderInfo->reduce_amount+$orderInfo->coupon_amount,2)?>
                </p>
            <?php endif;?>

            <?php if($orderInfo->member_money != 0) :?>
            <p class="goods-total">
                余额支付：¥
               <?=Yii::$app->formatter->asDecimal($orderInfo->member_money,2)?>
            </p>
            <?php endif;?>
            <?php if($orderInfo->order_amount != 0 || $orderInfo->try_coin != 0) :?>
            <p class="goods-total total-price">
                实付金额：¥
                <?php if($orderInfo->order_amount != 0) :?><?=Yii::$app->formatter->asDecimal($orderInfo->order_amount,2)?><?php endif;?>
                <?php if($orderInfo->order_amount != 0 && $orderInfo->try_coin != 0) :?>+<?php endif;?>
                <?php if($orderInfo->try_coin != 0) :?><?=$orderInfo->try_coin ?>试豆<?php endif;?>
            </p>
            <?php endif;?>
		</div>
        <?php endif ;?>
        
	</div>
</div>
<?php endif ;?>
<!-- 主体内容 End -->

<!-- 页脚 Start -->
<div class="footer"></div>
<!-- 页脚 End -->
<!--侧边栏-->
<?= $this->render('@liketry/views/layouts/sidebar.php')?>
<!--js-->
<?php $this->beginBlock('js');?>
<script src="<?=Yii::getAlias('@static')?>/pc/common/js/jquery-1.12.3.min.js"></script>
<script src="<?=Yii::getAlias('@static')?>/pc/common/js/lkt.pc.js"></script>
<script src="<?=Yii::getAlias('@static')?>/pc/liketry/js/order-detail.js"></script>
<?php $this->endBlock();?>
